<template>
  <div>
    <div>
      <slot name="btn" />
    </div>
    <el-table :data="tableData" style="width: 100%" border stripe @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" />
      <el-table-column type="index" label="序号" width="68" :index="indexMethod" />
      <el-table-column v-for="(item,index) in tableCol" :key="index" :prop="item.prop" :label="item.label" :width="item.width" />
      <el-table-column v-if="edit" fixed="right" label="操作" width="180">
        <template slot-scope="scope">
          <slot name="edit" :status="scope.row" />
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: {
    tableData: {
      type: Array,
      default: () => []
    },
    tableCol: {
      type: Array,
      default: () => []
    },
    current: {
      type: Number,
      default: () => 0
    },
    size: {
      type: Number,
      default: () => 0
    },
    edit: {
      type: Boolean,
      default: () => true
    }
  },
  data() {
    return {
      selArr: []
    }
  },
  methods: {
    handleClick(row) {
      console.log(row)
    },
    indexMethod(index) {
      return (this.current - 1) * this.size + index + 1
    },
    handleSelectionChange(val) {
      this.selArr = val
    }
  }
}
</script>
<style>
.el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 44px;
    text-align: center;
  }
.el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 55px;
    color: #909399;
    font-weight: 500;
    background-color: #f9f6ee;
    text-align: center;
}
</style>

